package com.yupi.yoj.controller;

import com.yupi.yoj.common.BaseResponse;
import com.yupi.yoj.common.ResultUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MQController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/testMQ/{queueName}/{routingKey}/{msg}")
    public BaseResponse<String> testMQ(@PathVariable("queueName") String queueName, @PathVariable("routingKey") String routingKey, @PathVariable("msg") String msg) {
        rabbitTemplate.convertAndSend(queueName, routingKey, msg);
        return ResultUtils.success("发送成功");
    }
}
